<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<!--分页 参数：现在的页面 分页条的大小 总页面数 跳转地址前缀-->
<nav th:fragment="page-navigation-search(currentPage,barSize,totalPage,addressPrefix,addressSuffix)" style="float: right" th:if="${totalPage > 1}">
    <ul class="pagination">
        <li class="page-item" th:if="${currentPage>1}">
            <a class="page-link" th:href="@{${addressPrefix} + '/' +${currentPage - 1} + '/' + '20' + ${addressSuffix}}"
               aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
            </a>
        </li>

        <!--totalPage小于等于barSize-->
        <li th:class="${currentPage==i ? 'page-item active' : 'page-item'}" th:if="${totalPage<=barSize}"
            th:each="i : ${#numbers.sequence(1,totalPage)}">
            <a class="page-link" th:href="@{${addressPrefix} + '/' + ${i} + '/' + '20' + ${addressSuffix}}" th:text="${i}"></a>
        </li>

        <!--前-->
        <li th:class="${currentPage==i ? 'page-item active' : 'page-item'}"
            th:if="${totalPage>barSize  && currentPage<=(barSize/2 + 1)}"
            th:each="i : ${#numbers.sequence(1,barSize)}">
            <a class="page-link" th:href="@{${addressPrefix} + '/' + ${i} + '/' + '20' + ${addressSuffix}}" th:text="${i}"></a>
        </li>
        <!--中-->
        <li th:class="${currentPage==i ? 'page-item active' : 'page-item'}"
            th:if="${totalPage>barSize  && currentPage>=(barSize/2 + 2) && currentPage<=(totalPage - barSize/2)}"
            th:each="i : ${#numbers.sequence(currentPage - barSize/2,currentPage + barSize/2)}">
            <a class="page-link" th:href="@{${addressPrefix} + '/' + ${i} + '/' + '20' + ${addressSuffix}}" th:text="${i}"></a>
        </li>
        <!--后-->
        <li th:class="${currentPage==i ? 'page-item active' : 'page-item'}"
            th:if="${totalPage>barSize  && currentPage>=(totalPage - barSize/2 + 1)}"
            th:each="i : ${#numbers.sequence(totalPage - barSize + 1,totalPage)}">
            <a class="page-link" th:href="@{${addressPrefix} + '/' + ${i} + '/' + '20' + ${addressSuffix}}" th:text="${i}"></a>
        </li>

        <li class="page-item" th:if="${currentPage<totalPage}">
            <a class="page-link" th:href="@{${addressPrefix} + '/' + ${currentPage + 1} + '/' + '20' + ${addressSuffix}}"
               aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
            </a>
        </li>
    </ul>
</nav>
</html>